#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 1024

int main(){
  int rfd = open("ComFIFO", O_RDONLY);
  if(rfd < 0){
    perror("open");
    exit(-1);
  }
  char buffer[BUF_SIZE];
  while(1){
    memset(buffer, 0, BUF_SIZE);        
    int ret = read(rfd, buffer, BUF_SIZE - 1);
    if(ret < 0){
      perror("read");                     
      exit(0);                           
    }
    else if(ret == 0){
      continue;
    }
    printf("Client Say:%s", buffer);
    fflush(stdout);
  }
  close(rfd);
  return 0;
}
